package com.jxsm.controller;

import com.jxsm.pojo.Contract;
import com.jxsm.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/11/1.
 */
@Controller
public class ContractContraller extends   BaseController{
    @Autowired
    private ContractService contractService;

    @RequestMapping("/cargo/contract/contract.action")
    public String  findAll(Map<String ,Object>map){
        map.put("contracts",contractService.find(null));
        return "/cargo/contract/contract.jsp";
    }
@RequestMapping("/cargo/contract/toview.action")
    public String view(String id,Map<String ,Object>map) {
    map.put("obj",contractService.get(id));
    return "\\cargo\\contract\\contractView.jsp";
}
//转向新增页面
@RequestMapping("/cargo/contract/tocreate.action")
    public String insert(){
    return "/cargo/contract/contractInsert.jsp";
}
//完成新增
    @RequestMapping("/cargo/contract/contractCreate.action")
    public String create(Contract contract){
        contractService.insert(contract);
        return "redirect:/cargo/contract/contract.action";
    }
    @RequestMapping("/cargo/contract/toupdate.action")
    public String toupdate(String id,Map<String,Object>map){
    map.put("obj",contractService.get(id));
    return "/cargo/contract/ContractUpdate.jsp";
}
@RequestMapping("/cargo/contract/update.action")
    public String update(Contract contract){
      contractService.update(contract);
    return "redirect:/cargo/contract/contract.action";
}
@RequestMapping("/cargo/contract/deleteById.action")
    public String deleteById(String id){
    contractService.deleteById(id);
    return "redirect:/cargo/contract/contract.action";
}
@RequestMapping("/cargo/contract/delete.action")
    public String delete(@RequestParam("id") String [] ids){
    contractService.delete(ids);
    return "redirect:/cargo/contract/contract.action";
}
@RequestMapping("/cargo/contract/start.action")
    public String start(@RequestParam("id")String[] ids){
    contractService.start(ids);
    return "redirect:/cargo/contract/contract.action";
}
    @RequestMapping("/cargo/contract/stop.action")
    public String stop(@RequestParam("id")String[] ids) {
        contractService.stop(ids);
        return "redirect:/cargo/contract/contract.action";
    }
}
